import java.util.Scanner;
import java.util.*;

public class MC0462最后一难 {
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        // code here
        String s = input.next();
        int count = 0;
        for (int i = 0; i + 6 <= s.length(); i++) {
            if (s.substring(i, i + 6).equals("matiji")) {
                count++;
            }
        }
        System.out.println(count);
        input.close();
    }
}
